package com.shop.product.controller;

import com.shop.common.core.domain.Result;
import com.shop.common.core.web.controller.BaseController;
import com.shop.common.core.web.page.TableDataInfo;
import com.shop.common.log.annotation.Log;
import com.shop.common.log.enums.BusinessType;
import com.shop.common.security.annotation.RequiresPermissions;
import com.shop.product.domain.MallProductBrandInfo;
import com.shop.product.domain.MallProductRuleInfo;
import com.shop.product.service.MallProductRuleInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("productRuleInfo")
public class MallProductRuleInfoController extends BaseController {
    @Autowired
    MallProductRuleInfoService mallProductRuleInfoService;

    /**
     * 查询商品规格信息
     * @param mallProductRuleInfo
     * @return
     */
    @RequiresPermissions("product:productRuleInfo:list")
    @GetMapping("/list")
    public Result<TableDataInfo> list(MallProductRuleInfo mallProductRuleInfo){
        startPage();
        List<MallProductRuleInfo> list=mallProductRuleInfoService.selectMallProductRuleInfoList(mallProductRuleInfo);
        return getDataTable(list);
    }

    /**
     * 添加商品规则
     * @param mallProductRuleInfo
     * @return
     */
    @RequiresPermissions("product:productRuleInfo:add")
    @Log(title = "商品规则", businessType = BusinessType.INSERT)
    @PostMapping
    public Result add(@RequestBody MallProductRuleInfo mallProductRuleInfo){
        return toAjax(mallProductRuleInfoService.insertMallProductRuleInfo(mallProductRuleInfo)) ;
    }
}
